package cn.iocoder.yudao.module.hs.dal.mysql.device;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.hs.controller.admin.device.vo.DevicePageReqVO;
import cn.iocoder.yudao.module.hs.dal.dataobject.device.DeviceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 基站信息 Mapper
 *
 * @author 航盛
 */
@Mapper
public interface DeviceMapper extends BaseMapperX<DeviceDO> {

    default PageResult<DeviceDO> selectPage(DevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceDO>()
                .likeIfPresent(DeviceDO::getCode, reqVO.getCode())
                .eqIfPresent(DeviceDO::getIp, reqVO.getIp())
                .eqIfPresent(DeviceDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(DeviceDO::getWaitingArea, reqVO.getWaitingArea())
                .betweenIfPresent(DeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceDO::getId));
    }

    default List<DeviceDO> selectList(List<String> deviceIds) {
        return selectList(new LambdaQueryWrapperX<DeviceDO>()
                .inIfPresent(DeviceDO::getCode, deviceIds));
    }
}
